<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>LingPowerAI</title>
		<script type="text/javascript">
			//打开引导
			var firstGuide = localStorage.getItem("guide");
			if (firstGuide != "yes") {
				window.location.href = 'guide.html'; //启动引导页
			}
		</script>
		  <script type="text/javascript">
		  	document.write('<script src="../js/fix.js?rd=?rd=' + Math.random() + '"><\/script>');
		  </script>
		  <script type="text/javascript">
		  	link(['../css/mui.min.css', '../css/icons-extra.css'], true);
		  </script>
            
	<!-- 	<style type="text/css">
			.mui-tab-label{
				color: white;
				}
				.mui-tab-item .mui-icon{
					color: white;
				}.
		</style> -->
		<style type="text/css">
			.mui-active .mui-icon,.mui-active .mui-tab-label{
				color:#47BAFE ;
			}
			.mui-bar-nav{
				background: #47BAFE;
				}
				.mui-title{
					color: #FFFFFF;
				}
			*{ touch-action: none; }
		</style>
	</head>

	<body style="background: #FFFFFF;">
			<!-- 	<header class="mui-bar mui-bar-nav" st>
					<h1 class="mui-title" id="title">首页</h1>
				</header> -->
		 <div class="mui-content">
		    <nav id="bar" class="mui-bar mui-bar-tab">
		        <a class="mui-tab-item mui-active" href="home/home.html" data-id="home">
		            <span class="mui-icon mui-icon-home"></span>
		            <span class="mui-tab-label">首页</span>
		        </a>
		        <a class="mui-tab-item" href="customer/customer.html" data-id="customer">
		            <span class="mui-icon mui-icon-email"></span>
		            <span class="mui-tab-label">消息</span>
		        </a>
		        <a class="mui-tab-item" href="services/services.html" data-id="services">
		            <span class="mui-icon mui-icon-contact"></span>
		            <span class="mui-tab-label">通讯录</span>
		        </a>
		        <a class="mui-tab-item" href="mine/mine.html" data-id="mine">
		            <span class="mui-icon mui-icon-gear"></span>
		            <span class="mui-tab-label">设置</span>
		        </a>
		    </nav>
		</div>
	</body>
		<script type="text/javascript">
		script(['../js/mui.min.js', '../libs/md5.min.js', '../js/app/constants.js', '../js/app/common.js'], true);
	</script>
	<script type="text/javascript">
		var closeLoad = false;
		mui.init();
	 var showMenu = false,
	 	showPop = "";
		// var subPages = ["home/home.html", "customer/customer.html", "services/services.html", "mine/mine.html"];
		mui.plusReady(function() {
					 plus.navigator.setStatusBarStyle("UIStatusBarStyleBlackOpaque");
			plus.navigator.setStatusBarBackground('#47BAFE');
				plus.navigator.setStatusBarBackground('#47BAFE');
			plus.navigator.setStatusBarStyle('light');
				storage.init();
			storageUser = kidstorageuser.getInstance();
			if(!storageUser.IsLogin) { //未登录	
				// storageUser.loginOut(); //退出
				plus.storage.clear();
				openNew("login/login.html", {
					backid : "index.html"
				});
				return;
			} else {
				// 获取当前用户拥有的客户数量,如果没有客户,则跳转到客户诊断画面
				//requestJsonFile("../../data/home/NoneCustomer.json", {}, function(result_none) {
				request("/cmdb/CountCustomerBySalesId/", {sales_id:storageUser.UId}, function(result_none) {
						if (result_none[SysConstants.DATASET_KEY].CUST_CNT == 0) {
						openNew("customer/customerDiagnosis.html");
					}
				});
			}
			
			// var subPagesLoad = [false, false, false, false];
		      var self = plus.webview.currentWebview();
			  
		var current = '';
		var styles = {
		    top: '0',
		    bottom: '51px'
		};
			   var tabsConfig = {  
			            home: {  
			                url: 'home/home.html',  
			                styles: styles,  
			                default: true  
			            },  
			            customer: {  
			                url: 'customer/customer.html',  
			                styles: styles  
			            },  
			            services: {  
			                url: 'services/services.html',  
			                styles: styles  
			            },  
			            mine: {  
			                url: 'mine/mine.html',  
			                styles: styles  
			            }  
			        }; 
			    var tabs = {};
			    for (id in tabsConfig) {
			        tabs[id] = plus.webview.create(tabsConfig[id].url, id, tabsConfig[id].styles);
			        if (tabsConfig[id]['default']) {
			            self.append(tabs[id]);
			            current = id;
			        }
			    }
			    mui('#bar').on('tap', 'a', function(e) {
			        if (current == this.dataset.id) {
			            return;
			        }
			        // tabs[this.dataset.id].show();
					plus.webview.show(tabs[this.dataset.id],"fade-in",100);
			        tabs[current].hide();
			        current = this.dataset.id;
			    });
			});
		 		var backButtonPress = 0;
		 mui.back = function(event) {
		 	backButtonPress++;
		 	if (backButtonPress > 1) {
		 		plus.runtime.quit();
		 	} else {
		 		plus.nativeUI.toast('再按一次退出应用');
		 	}
		 	setTimeout(function() {
		 		backButtonPress = 0;
		 	}, 1000);
		 	return false;
		 };
	</script>
</html>
